<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Admin
 *
 * @author hodek
 */
class Admin {

    private $textEditName = "";
    private $actionEdit = "";
    private $adminId = "";
    private $propertyKey = array();
    private $propertyValue = null;
    private $role = "";
    private $email = "";
    private $lastImage = "";
    private $platba = "";
    private $celkCena = "";

    public function getTextEditName() {
        return $this->textEditName;
    }

    public function setTextEditName($textEditName) {
        $this->textEditName = $textEditName;
    }

    public function getRole() {
        return $this->role;
    }

    public function setRole($role) {
        $this->role = $role;
    }

    public function getLastImage() {
        return $this->lastImage;
    }

    public function setLastImage($lastImage) {
        $this->lastImage = $lastImage;
    }

    public function getEmail() {
        return $this->email;
    }

    public function setEmail($email) {
        $this->email = $email;
    }

    public function setProperty($key, $value) {
        $i = 0;
        foreach ($this->propertyKey as $variable) {
            if ($variable == $key) {
                $this->propertyValue[$i] = $value;
                return true;
            }
            $i++;
        }
        $count = count($this->propertyValue);
        $this->propertyKey[$count] = $key;
        $this->propertyValue[$count] = $value;
        return true;
    }

    public function getPropertyValue($key) {
        $i = 0;
        foreach ($this->propertyKey as $variable) {
            if ($variable == $key) {
                return $this->propertyValue[$i];
            }
            $i++;
        }
        return false;
    }

    /**
     *
     * @return Item[] 
     */
    public function getZbozi() {
        $ret = array();
        $count = 0;
        $i = 0;
        foreach ($this->propertyKey as $variable) {
            if ($variable == "zbozi") {
                $ret[$count] = $this->propertyValue[$i];
                $count++;
            }
            $i++;
        }
        return $ret;
    }

    public function setZbozi($item) {
        $count = count($this->propertyValue);
        $this->propertyKey[$count] = "zbozi";
        $this->propertyValue[$count] = $item;
        return true;
    }

    public function removeZbozi($item) {
        $i = 0;
        foreach ($this->propertyKey as $variable) {
            if ($variable == "zbozi") {
                if ($this->propertyValue[$i]->getVelikost() == $item->getVelikost() &&
                        $this->propertyValue[$i]->getBarva() == $item->getBarva() &&
                        $this->propertyValue[$i]->getItemId() == $item->getItemId() &&
                        $this->propertyValue[$i]->getMnozstvi() == $item->getMnozstvi()) {
                    $indexToMove = sizeof($this->propertyKey) - 1;
                    $this->propertyKey[$i] = $this->propertyKey[$indexToMove];
                    $this->propertyValue[$i] = $this->propertyValue[$indexToMove];
                    unset($this->propertyValue[$indexToMove], $this->propertyKey[$indexToMove]);
                    return true;
                }
            }
            $i++;
        }
        return false;
    }

    public function removeZboziAll() {
        $i = 0;
        foreach ($this->propertyKey as $variable) {
            if ($variable == "zbozi") {        
                unset($this->propertyValue[$i], $this->propertyKey[$i]);
            }
            $i++;
        }
    }

    public function issetProperty($key) {
        $i = 0;
        foreach ($this->propertyKey as $variable) {
            if ($variable == $key) {
                return isset($this->propertyValue[$i]);
            }
            $i++;
        }
        return false;
    }

    public function removeProperty($key) {
        $i = 0;
        $ret = false;
        foreach ($this->propertyKey as $variable) {
            if ($variable == $key) {
                $ret = $this->propertyValue[$i];
                $indexToMove = sizeof($this->propertyKey) - 1;
                $this->propertyKey[$i] = $this->propertyKey[$indexToMove];
                $this->propertyValue[$i] = $this->propertyValue[$indexToMove];
                unset($this->propertyValue[$indexToMove], $this->propertyKey[$indexToMove]);
                return $ret;
            }
            $i++;
        }
        return $ret;
    }

    public function getActionEdit() {
        return $this->actionEdit;
    }

    public function setActionEdit($actionEdit) {
        $this->actionEdit = $actionEdit;
    }

    public function getAdminId() {
        return $this->adminId;
    }

    public function setAdminId($adminId) {
        $this->adminId = $adminId;
    }

    public function setPlatba($platba) {
        $this->platba = $platba;
    }

    public function getPlatba() {
        return $this->platba;
    }

    public function setCenaCelk($celkCena) {
        $this->celkCena = $celkCena;
    }

    public function getCenaCelk() {
        return $this->celkCena;
    }

}

?>
